package com.explorati.design_pattern.creational.prototype;

//原型模式是在内存中进行二进制流的拷贝，肯定比直接new一个对象性能好很多
public class Test {

	public static void main(String[] args) throws CloneNotSupportedException {
		Mail mail = new Mail();
		mail.setContent("初始化的模板");
		System.out.println("初始化mail :" + mail);

		for (int i = 0; i < 10; i++) {
			// clone方法并不调用构造函数
			Mail mailTemp = (Mail) mail.clone();
			mailTemp.setName("姓名" + i);
			mailTemp.setEmailAddress("姓名" + i + "@imooc.com");
			mailTemp.setContent("恭喜您，中奖了");
			MailUtil.sendMail(mailTemp);
			System.out.println("克隆的mailTemp :" + mailTemp);
		}
		MailUtil.saveOriginMailRecord(mail);
	}
}
